﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Example04.aspx.cs" Inherits="Chapter28.Example04" %>

<!DOCTYPE html>

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>代码清单 28-4 使用属性方法</title>
    <meta name="author" content="Adam Freeman" />
    <meta name="description" content="A simple example" />
    <link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
    <style>
        p {
            border: medium double black;
        }
    </style>
</head>
<body>
    <p id="textblock" class="fruit numbers">
        There are lots of different kinds of fruit - there are you over 500 varieties 
        of <span id="banana">banana</span> alone. By the time we add the countless 
        types of <span id="apple">apples</span>, 
       <span id="orange">oranges</span>, and other well-known fruit, we are 
        faced with thousands of choices.
    </p>
    <pre id="results"></pre>
    <script>
        var results = document.getElementById("results");
        var elem = document.getElementById("textblock");

        results.innerHTML = "Element has lang attribute: " + elem.hasAttribute("lang") + "\n";
        results.innerHTML += "Adding lang attribute\n";
        elem.setAttribute("lang", "en-us");
        results.innerHTML += "Attr value is: " + elem.getAttribute("lang") + "\n";
        results.innerHTML += "Set new value for lang attribute\n";
        elem.setAttribute("lang", "en-uk");
        results.innerHTML += "value is now: " + elem.getAttribute("lang") + "\n";
    </script>
</body>
</html>
